#-----------------------------------------------------------------------------
# Project:     Multi-Programmer Game Demo
# Name:        Paddle.py
# Purpose:     Controllable Paddle Object
# 
# Authors:     Chris Spooner, Chris La-Roo
# Main Author: Chris Spooner
#
# Created:     11/30/2012
# Copyright:   (c) Chris Spooner 2012
# Licence:     New BSD
#-----------------------------------------------------------------------------
import pygame, math, sys, random
#stuff 
class Paddle():
    def __init__(self, maxSpeed, position):
        self.surfaces = []
        self.surfaces += [pygame.image.load("rsc/paddle/paddle.png")]
        self.frame = 0
        self.maxFrame = len(self.surfaces)-1
        self.surface = self.surfaces[self.frame]
        self.maxSpeed = maxSpeed
        self.rect = self.surface.get_rect()
        self.radius = (self.rect.width/2 +self.rect.height/2)/2          
        self.speed = [0,0]
        self.place(position)           
        self.living = True
        if pygame.mixer:
            self.bounceSound = pygame.mixer.Sound("bounce.wav")
        self.dir = "none"
        #taken from exorcist

        
        
        
    def  __str__(self):
        return "I'm a paddle" + str(self.rect.center)
     
    def place(self, position):
        print "I've moved to", position
        
    def move(self):
        self.rect = self.rect.move(self.speed)
        
    def collideWall(self, screenWidth, screenHeight):
        print "trying to hit edges of screen", screenWidth, screenHeight
        if (self.rect.left < 0 
            or self.rect.right > screenWidth):
            self.speed[0] = self.speed[0]*-1
        if (self.rect.top < 0 
            or self.rect.bottom > screenHeight):
            self.speed[1] = self.speed[1]*-1
            #taken fromm self
    
    def direction(self, dir):
        if dir == "up":
            self.speed[1] = -self.maxSpeed
            self.dir = "up"
        elif dir == "stop up":
            self.speed[1] = 0
            self.dir = "stop up"
        elif dir == "down":
            self.speed[1] = self.maxSpeed
            self.dir = "down"
        elif dir == "stop down":
            self.speed[1] = 0
            self.dir = "stop down"
        elif dir == "left":
            self.speed[0] = -self.maxSpeed
            self.dir = "left"
        elif dir == "stop left":
            self.speed[0] = 0
            self.dir = "stop left"
        elif dir == "right":
            self.speed[0] = self.maxSpeed
            self.dir = "right"
        elif dir == "stop right":
            self.speed[0] = 0
            self.dir = "stop right"
        #taken from exorcist